﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DuJianliang.ApplicationPlatform.Proj5715.Process
{
    public partial class ProcessCheck : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["DispatchMissileProcessID"] != null)
                {
                    ViewState["DispatchMissileProcessID"] = Request.QueryString["DispatchMissileProcessID"].Trim();
                    rbl_InspectionState.Attributes.Add("onclick", "checkState();");
                }
            }
        }

        protected void btn_OK_Click(object sender, EventArgs e)
        {
            //检验状态(1合格，2不合格)
            string InspectionState = rbl_InspectionState.SelectedValue;
            //不合格类型（1返修，2返工，3报废，4让步使用）
            string UnqualifiedType = ddl_UnqualifiedType.SelectedValue;

            var dal = new ProcessDal();

            switch (InspectionState)
            {
                case "1":
                    dal.ProcessCheck(ViewState["DispatchMissileProcessID"].ToString(), "1", "");
                    break;

                case "2":
                    switch (UnqualifiedType)
                    {
                        case "1":
                            dal.ProcessCheck(ViewState["DispatchMissileProcessID"].ToString(), "2", "1");
                            dal.ProcessReInsert(ViewState["DispatchMissileProcessID"].ToString());
                            break;
                        case "2":
                            dal.ProcessCheck(ViewState["DispatchMissileProcessID"].ToString(), "2", "2");
                            dal.ProcessReInsert(ViewState["DispatchMissileProcessID"].ToString());
                            break;
                        case "3":
                            
                            dal.ProcessCheck(ViewState["DispatchMissileProcessID"].ToString(), "2", "3");
                            break;
                        case "4":
                            dal.ProcessCheck(ViewState["DispatchMissileProcessID"].ToString(), "2", "4");
                            break;
                    }

                    break;
            }

            Response.Write("<script>window.opener = null;window.open('', '_self', '');window.close();</script>");
        }
    }
}